import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';

extension ExtensionDialog on GetInterface {
  void showCupertinoDialog({
    String content = '',
    TextStyle? contentStyle,
    String leftText = '否',
    TextStyle? leftStyle,
    VoidCallback? onLeftTap,
    String rightText = '是',
    TextStyle? rightStyle,
    VoidCallback? onRightTap,
  }) {
    SmartDialog.show(
      builder: (context) => Container(
        width: 540.w,
        height: 280.h,
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(28.w),
        ),
        child: Stack(
          alignment: Alignment.topCenter,
          children: [
            Positioned(
              top: 74.h,
              child: Text(
                content,
                style: contentStyle ??
                    TextStyle(
                      fontSize: 32.sp,
                      color: const Color(0XFF6D6D6D),
                    ),
              ),
            ),
            Positioned(
              left: 0,
              bottom: 0,
              width: 269.w,
              height: 88.h,
              child: CupertinoDialogAction(
                onPressed: () {
                  SmartDialog.dismiss();
                  onLeftTap?.call();
                },
                child: Text(
                  leftText,
                  style: TextStyle(
                    fontSize: 32.sp,
                    color: const Color(0XFF6D6D6D),
                  ).merge(leftStyle),
                ),
              ),
            ),
            Positioned(
              right: 0,
              bottom: 0,
              width: 269.w,
              height: 88.h,
              child: CupertinoDialogAction(
                onPressed: () {
                  SmartDialog.dismiss();
                  onRightTap?.call();
                },
                child: Text(
                  rightText,
                  style: TextStyle(
                    fontSize: 32.sp,
                    color: const Color(0XFF1774E0),
                  ).merge(rightStyle),
                ),
              ),
            ),
            Positioned(
              bottom: 88.h,
              left: 0,
              right: 0,
              height: 2.h,
              child: Container(
                color: const Color(0XFFF0F2F7),
                height: 2.h,
              ),
            ),
            Positioned(
              bottom: 0,
              width: 2.w,
              child: Container(
                color: const Color(0XFFF0F2F7),
                height: 88.h,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
